home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / dbu / sysmon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  3.5 KB  |  230 lines

  1. # include    <ingres.h>
  2. # include    <version.h>
  3. # include    <opsys.h>
  4. # include    <pv.h>
  5. # include    <func.h>
  6. # include    <signal.h>
  7. # include    <pipes.h>
  8. # include    <setjmp.h>
  9. # include    <string.h>
  10. # include     <symbol.h>
  11.  
  12. /*
  13. **    SYSTTYMON - 
  14. **        sets up the pipe block for the sysmod function,
  15. **        and passed the -R flags in the parmvector.
  16. **
  17. **        note: this is kludged in the same way that the
  18. **            ingres monitor is-- there is no systm_mon.
  19. **            all work is done in systm_init.
  20. **
  21. */
  22.  
  23. void    systm_mon();
  24. void    systm_init();
  25. void    syssetp(int, char *, int);
  26.  
  27. short        tTsysttymon[100];
  28. PARM        pv[PV_MAXPC+ 1];
  29. int        pc;
  30. extern jmp_buf  CmReset;
  31.  
  32. struct fn_def    SysTtyMonFn =
  33. {
  34.     "SYSMONITOR",
  35.     systm_mon,
  36.     systm_init,
  37.     NULL,
  38.     NULL,
  39.     0,
  40.     tTsysttymon,
  41.     100,
  42.     'S',
  43.     0
  44. };
  45.  
  46. void
  47. systm_init(argc, argv)
  48. int    argc;
  49. char    *argv[];
  50. {
  51.     pb_t        pb;
  52.     char        **p;
  53.     char        *pp;
  54.  
  55.     /*
  56.     **    THIS CODE IS A CLUDGE!!!
  57.     **
  58.     **    all work is done in the init function 
  59.     **     so that the sysmonitor will have control
  60.     **    before the sysmod function.
  61.     */
  62.  
  63.     setjmp(CmReset);
  64.  
  65.     /* arrange to call the sysfunc */
  66.     for ( p = &argv[6]; (pp = *p) != NULL; p++)
  67.     {
  68.         pp = *p;
  69.         if (pp[1] == 'S')
  70.             continue;
  71.         syssetp(PV_STR, pp, 0);
  72.     }
  73.     call_setup(&pb, mdSYSFUNC, NULL);
  74.     pb_prime(&pb, PB_REG);
  75.     pb.pb_proc = 1;        /**** SYSFUNC MUST BE IN PROC ONE ****/
  76.     send_off(&pb, pc, pv);
  77.     pb_tput(PV_EOF, "", 0, &pb);
  78.     pb_flush(&pb);
  79.  
  80.     /* wait for the response */
  81.     readinput(&pb);
  82.     resetp();
  83.     exit(0);
  84. }
  85. /*
  86. **  SYSSETP -- set parameter
  87. **
  88. **    Sets a parameter, to be later sent by 'call' to whomever.
  89. **    This looks suspiciously like ctlmod/setp.c, except
  90. **    it sets a local pc and pv, and doesnt need to know anything
  91. **    about the Ctx struct.
  92. **
  93. **    Parameters:
  94. **        type -- parameter type.
  95. **            PV_STRING -- a string, 'len' is ignored.
  96. **            PV_INT -- an integer, 'len' is ignored.
  97. **        val -- the value (real value if PV_INT, pointer
  98. **            otherwise).
  99. **        len -- the length of the tuple.
  100. **
  101. **    Returns:
  102. **        none
  103. **
  104. **        Adjusts pc & pv.
  105. **
  106. */
  107.  
  108. void
  109. syssetp(type, val, len)
  110. register int    type;
  111. char        *val;
  112. register int    len;
  113. {
  114.     PARM    *pp;
  115.     char    *newp;
  116.     extern char    *need();
  117.     char    *buf;
  118.  
  119.     /*
  120.     **  Check the magic bounds.
  121.     */
  122.  
  123.     pp = &pv[pc++];
  124.  
  125.     /*
  126.     **  Figure out the length from the type.
  127.     */
  128.  
  129.     switch (type)
  130.     {
  131.       case PV_STR:
  132.         len = length(val) + 1;
  133.         newp = need(Qbuf, len);
  134.         bmove(val, newp, len);
  135.         buf = newp;
  136.         pp->pv_val.pv_str = newp;
  137.         break;
  138.     
  139.       case PV_INT:
  140.         len = sizeof (short);
  141.         pp->pv_val.pv_int = (int) val;
  142.         break;
  143.  
  144.     
  145.       default:
  146.         syserr("syssetp: type %d", type);
  147.     }
  148.  
  149.     /*
  150.     **  Set up the parameter.
  151.     */
  152.  
  153.     pp->pv_type = type;
  154.     pp->pv_len = len;
  155.  
  156. # ifdef xSTR1
  157.     if tTf(0,0)
  158.     {
  159.         lprintf("syssetp: ");
  160.         pr_parm(pp);
  161.     }
  162. # endif
  163. }
  164. /*
  165. **  SYSTM_MON -- "function to implement this module"
  166. **
  167. **    Since we have cludged up this module to work, and hence
  168. **    the init routine should never return, this routine just
  169. **    syserr's.
  170. */
  171.  
  172. void
  173. systm_mon()
  174. {
  175.     syserr("systm_mon");
  176. }
  177. /*
  178. **  ACC_INIT, PAGEFLUSH -- dummy access method routines
  179. **
  180. **    Since the CM wants to do some basic access method functions,
  181. **    we will let it.
  182. */
  183.  
  184. void
  185. acc_init()
  186. {
  187. }
  188.  
  189. int
  190. pageflush(x)
  191. char    *x;
  192. {
  193.     return (0);
  194. }
  195. /*
  196. **  CLOSECATALOG -- dummy catalog close routine.
  197. **
  198. **    To keep from loading access methods.
  199. */
  200.  
  201. void
  202. closecatalog()
  203. {
  204. }
  205.  
  206.  
  207. /*
  208. **  GET FLAG
  209. **
  210. */
  211.  
  212. int
  213. getflag(argv, dest)       /* need some data structure to hold the flags */
  214. char    **argv;
  215. char     **dest;
  216. {
  217.     int        destctr;
  218.     int        i;
  219.  
  220.     destctr = 0;
  221.     for (i = 0; i <= 6; i++)
  222.     {
  223.         if (argv[i][0] != NULL)
  224.             strcpy( dest[destctr++], argv[i]);
  225.         else
  226.             return(0);
  227.     }
  228.     return(0);
  229. }
  230.